<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加商品</title>
    <style>
        body{
            margin: 0 auto;
            text-align: center;
            background-image: url("img/img.png");
            background-size: cover;
        }
    </style>
</head>
<body>
<h1 style="color: white">添加商品</h1>
<div>
  <input type="text" v-model="product.title" placeholder="请输入标题"><br>
  <input type="text" v-model="product.price" placeholder="请输入价格"><br>
  <input type="text" v-model="product.saleCount" placeholder="请输入销量"><br>
  <input type="button" value="添加" @click="insertPro()">
</div>

<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>

<script>
  let v = new Vue({
    el:"div",
    data:{
      product:{title:"",price:"",saleCount:""}
    },
    methods:{
      insertPro(){
        axios.post("insertPro",v.product).then(function (response){
            if(response.data==1){
                alert("添加成功!");
                location.href="selectAll.html";
            }else{
                alert("商品已存在!");
            }
        })
      }
    }
  })
</script>
</body>
</html>